<!DOCTYPE HTML>
<%@page import="shop.vo.AddressBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="shop.vo.OrderBean"%>
<%@page import="java.util.List"%>
<%@page import="shop.vo.UserBean"%>
<%@page import="shop.factory.DAOFactory"%>
<html>
<head>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<meta charset="utf-8">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<script src="../js/jquery-1.10.2.min.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<title>订单页面</title>
<style type="text/css">
.foot-heiht {
	text-align: center;
	line-height: 50px;
}
th {
	text-align: center;
}
</style>
<title>订单页面</title>
</head>
<%
	String username = (String)session.getAttribute("user");
	UserBean user = new UserBean();
	user.setUser_name(username);
	int id = DAOFactory.getIUserDAOInstance().findId(user);
	List<OrderBean> list = DAOFactory.getIOrderDAOInstance().findByUserId(id);
	Iterator<OrderBean> it = list.iterator();
%>
<body>
	<nav class="navbar navbar-default" role="navigation">
		<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse"
				data-target="#bs-example-navbar-collapse-1">
				<span class="sr-only">Toggle navigation</span> <span
					class="icon-bar"></span> <span class="icon-bar"></span> <span
					class="icon-bar"></span>
			</button>
		</div>
		<div class="collapse navbar-collapse"
			id="bs-example-navbar-collapse-1">
			<ul class="nav navbar-nav">
				<li class="active"><a href="../index.jsp">首页</a></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyOrder"> <img src="../images/order.png" /> 我的订单
				</a></li>
				<li></li>
				<li><a href="<%=request.getContextPath() %>/OrderServlet?action=MyCart"> <img src="../images/car.png" /> 我的购物车
				</a></li>
				<li><a href="<%=request.getContextPath() %>/FavoriteServlet?action=MyFav"> <img src="../images/favorite.png" /> 我的收藏
				</a></li>
				<li><a href="<%=request.getContextPath() %>/AddressServlet?action=MyAddress"> <img src="../images/address.png" /> 我的地址簿
				</a></li>
			</ul>

			<ul class="nav navbar-nav navbar-right">
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=xinxi"><span id="huanying">欢迎光临，游客</span></a></li>
				<li><a href="../Login/login.jsp">登陆</a></li>
				<li><a href="../Login/regist.jsp">注册</a></li>
				<li><a href="<%=request.getContextPath() %>/UserServlet?action=logout" class="active" onclick="return confirm('确认退出?')">退出</a></li>
			</ul>
		</div>
	</nav>

	<div class="container">
		<div class="col-md-4">
			<img src="../images/logo.png" />
		</div>
		<h3>订单详情</h3>
		<div class="col-lg-12">
			<div class="table-responsive">
				<form action="" method="post">
					<table class="table">
						<thead>
							<tr>
								<th>序号</th>
								<th>商品名称</th>
								<th>收货人</th>
								<th>地址</th>
								<th>电话</th>
								<th>订单状态</th>
								<th>下单时间</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<%
								while (it.hasNext()) {
									OrderBean order = it.next();
									UserBean user1 = order.getUser();
									AddressBean addr = order.getAddr();
									int i = order.getOrder_state();
									String str = null;
									switch (i) {
										case 1:str = "未处理";break;
										case 2:str = "已备货";break;
										case 3:str = "已发货";break;
										case 4:str = "已完成";break;
										default:break;
									}
							%>
							<tr>
								<td class="success" align="center"><%=order.getOrder_id() %></td>
								<td class="danger" align="center"><%=order.getOrder_pro() %></td>
								<td class="danger" align="center"><%=user1.getUser_name() %></td>
								<td class="danger" align="center"><%=addr.getAddr_address() %></td>
								<td class="danger" align="center"><%=user1.getUser_mobile() %></td>
								<td class="danger" align="center"><%=str %></td>
								<td class="danger" align="center"><%=order.getOrder_time() %></td>
								<td class="danger" align="center"><a href="<%=request.getContextPath() %>/OrderServlet?action=deleteOrder&orderId=<%=order.getOrder_id() %>" onclick="return confirm('是否删除？')">删除</a><br>
								<a href="<%=request.getContextPath() %>/OrderServlet?action=talk&order_pro=<%=order.getOrder_pro() %>">评价</a>
								</td>
							</tr>
							<%
								}
							%>
						</tbody>
					</table>
				</form>
			</div>
		</div>
	</div>
</body>
<script type="text/javascript">
<%
	String str = (String)session.getAttribute("user");
	if (session.getAttribute("user") != null) {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，<%=str%>";
<%
	} else {
%>
document.getElementById("huanying").innerHTML = "欢迎光临，游客";
<%
	}
%>
</script>
</html>